import { ajaxService } from '@/utils/request';

const env = import.meta.env;
// const baseURL = env.VITE_API_BASE_URL;
// const baseURL = env.VITE_DEV_BASE_URL;
const baseURL = env.VITE_DEV_BASE_URL;
// const baseURL = 'http://192.168.31.129:39001';
// const baseURL = 'http://192.168.31.129:39001';
// const baseURL = 'http://192.168.31.183:39001';

// 获取职位层级数据
export function getPositionHierarchyList(params: any) {
  return ajaxService({
    url: '/hr/organization/basic_setting/position_system/position_level',
    method: 'get',
    noToken: false,
    params,
    baseURL
  });
}

// 根据职位id获取职位层级数据
export function getPositionHierarchyListById(params: {
  id: number; // 职位id
  type: 1 | 2; // 1获取职位层级 2获取职级
}) {
  return ajaxService({
    url: '/hr/organization/basic_setting/position_system/position_level/detail',
    method: 'get',
    params,
    baseURL
  });
}
// 新增职位层级数据
export function addPositionHierarchyList(data: any) {
  return ajaxService({
    url: '/hr/organization/basic_setting/position_system/position_level',
    method: 'post',
    noToken: false,
    data,
    isLoading: true,
    baseURL
  });
}

// 新增职位层级数据查重
export function CheckPositionHierarchyList(params: any) {
  return ajaxService({
    url: '/hr/organization/basic_setting/position_system/position_level/repeat',
    method: 'get',
    params,
    baseURL
  });
}

// 删除职位层级数据
export function delPositionHierarchyList(data: any) {
  return ajaxService({
    url: '/hr/organization/basic_setting/position_system/position_level',
    method: 'DELETE',
    noToken: false,
    data,
    baseURL
  });
}
// 修改职位层级数据
export function setPositionHierarchyList(data: any) {
  return ajaxService({
    url: '/hr/organization/basic_setting/position_system/position_level',
    method: 'put',
    noToken: false,
    data,
    isLoading: true,
    baseURL
  });
}
// 获取职务级别数据
export function getJobLevelList(params: any) {
  return ajaxService({
    url: '/hr/organization/basic_setting/position_system/job_level',
    // url: '/organization/position/set/postLevel',
    method: 'get',
    noToken: false,
    params,
    baseURL
  });
}
// 新增职务级别数据
export function addJobLevelList(data: any) {
  return ajaxService({
    url: '/hr/organization/basic_setting/position_system/job_level',
    method: 'post',
    noToken: false,
    data,
    isLoading: true,
    baseURL
  });
}
// 删除职务级别数据
export function delJobLevelList(data: any) {
  return ajaxService({
    url: '/hr/organization/basic_setting/position_system/job_level',
    // url: '/organization/position/set/postLevel',
    method: 'DELETE',
    noToken: false,
    data,
    baseURL
  });
}
// 修改职务级别数据
export function setJobLevelList(data: any) {
  return ajaxService({
    url: '/hr/organization/basic_setting/position_system/job_level',
    // url: '/organization/position/set/postLevel',
    method: 'put',
    noToken: false,
    data,
    isLoading: true,
    baseURL
  });
}

// 新增修改职务级别查重
export function CheckJobSortLevelList(params: any) {
  return ajaxService({
    url: '/hr/organization/basic_setting/position_system/job_level/repeat',
    // url: '/organization/position/postLevel/repeat',
    method: 'get',
    noToken: false,
    params,
    baseURL
  });
}

// 获取职务分类数据
export function getJobSortList(params: any) {
  return ajaxService({
    url: '/hr/organization/basic_setting/position_system/job_category',
    // url: '/organization/position/set/sort',
    method: 'get',
    noToken: false,
    params,
    baseURL
  });
}

// 修改职务分类数据
export function setJobSortList(data: any) {
  return ajaxService({
    url: '/hr/organization/basic_setting/position_system/job_category',
    // url: '/organization/position/set/sort',
    method: 'put',
    noToken: false,
    data,
    isLoading: true,
    baseURL
  });
}
// 增加职务分类数据
export function addJobSortList(data: any) {
  return ajaxService({
    url: '/hr/organization/basic_setting/position_system/job_category',
    // url: '/organization/position/set/sort',
    method: 'post',
    noToken: false,
    data,
    isLoading: true,
    baseURL
  });
}

// 增加职务分类数据查重
export function CheckJobSortList(params: any) {
  return ajaxService({
    url: '/hr/organization/basic_setting/position_system/job_category/repeat',
    // url: '/organization/position/sort/repeat',
    method: 'get',
    params,
    baseURL
  });
}

// 删除职务分类数据
export function delJobSortList(data: any) {
  return ajaxService({
    url: '/hr/organization/basic_setting/position_system/job_category',
    // url: '/organization/position/set/sort',
    method: 'DELETE',
    noToken: false,
    data,
    baseURL
  });
}

// 获取职位类别数据
export function getPositionSortList() {
  return ajaxService({
    url: '/hr/organization/basic_setting/position_system/position_category',
    method: 'get',
    baseURL
  });
}
// 新增修改职位类别数据查重
export function CheckPositionSortList(params: any) {
  return ajaxService({
    url: '/hr/organization/basic_setting/position_system/position_category/repeat',
    method: 'get',
    baseURL,
    params
  });
}

// 修改职位类别数据
export function setPositionSortList(data: any) {
  return ajaxService({
    url: '/hr/organization/basic_setting/position_system/position_category',
    method: 'put',
    data,
    isLoading: true,
    baseURL
  });
}

// 新增职位类别数据
export function addPositionSortList(data: any) {
  return ajaxService({
    url: '/hr/organization/basic_setting/position_system/position_category',
    method: 'post',
    data,
    isLoading: true,
    baseURL
  });
}

// 删除职位类别数据
export function delPositionSortList(data: any) {
  return ajaxService({
    url: '/hr/organization/basic_setting/position_system/position_category',
    method: 'DELETE',
    data,
    baseURL
  });
}

// 新增职位类别模板
export function PostPositionTemplate(data: any) {
  return ajaxService({
    url: '/hr/organization/template',
    method: 'post',
    data,
    isLoading: true,
    baseURL: baseURL
  });
}

// 修改职位类别模板
export function PutPositionTemplate(data: any) {
  return ajaxService({
    url: '/hr/organization/template',
    method: 'put',
    data,
    isLoading: true,
    baseURL: baseURL
  });
}

// 新增修改职位类别模板查重
export function CheckPositionTemplate(params: any) {
  return ajaxService({
    url: '/hr/organization/template/repeat',
    method: 'get',
    params,
    baseURL: baseURL
  });
}

// 获取职位类别模板列表
export function GetPositionTemplate(params: any) {
  return ajaxService({
    url: '/hr/organization/template',
    method: 'get',
    params,
    baseURL: baseURL
  });
}

// 根据职位类别id查职位类别编码
export function GetPositionTypeCodeById(params: any) {
  return ajaxService({
    url: '/hr/organization/basic_setting/position_system/position_category/code',
    method: 'get',
    params,
    baseURL: baseURL
  });
}

// 获取职位类别模板详情
export function GetPositionTemplateDetail(params: any) {
  return ajaxService({
    url: '/hr/organization/template/detail',
    method: 'get',
    params,
    baseURL: baseURL
  });
}

// 删除模板子集
export function DelPositionTemplateCollections(data: any) {
  return ajaxService({
    url: '/hr/organization/template/collection',
    method: 'delete',
    baseURL: baseURL,
    data
  });
}

// 删除模板子集里面的控件
export function DelPositionTemplateControls(data: any) {
  return ajaxService({
    url: '/hr/organization/template/control',
    method: 'delete',
    baseURL: baseURL,
    data
  });
}

// 删除职位类别模板数据
export function DelPositionTemplate(data: any) {
  return ajaxService({
    url: '/hr/organization/template',
    method: 'delete',
    data,
    baseURL: baseURL
  });
}

// 修改职位默认模板状态
export function PutPositionTemplateState(data: any) {
  return ajaxService({
    url: '/hr/organization/pattern/template/default',
    method: 'put',
    data,
    baseURL: baseURL
  });
}

// 合并数据到子模板
export function PutPositionTemplateMerge(data: any) {
  return ajaxService({
    url: '/organization/position/merge/set',
    method: 'put',
    data,
    baseURL: baseURL
  });
}

// 获取职位类别默认模板
export function GetPositionDefaultTemplate(params: any) {
  return ajaxService({
    url: '/organization/position/require',
    method: 'get',
    baseURL: baseURL,
    params
  });
}

// 获取职位类别对应模板
export function GetPositionTemplateCid(params: any) {
  return ajaxService({
    url: '/organization/position/pid/set',
    method: 'get',
    baseURL: baseURL,
    params
  });
}

// 获取职位矩阵数据
export function GetPositionSystem() {
  return ajaxService({
    url: '/hr/organization/position_management/position_management/position/system',
    method: 'get',
    baseURL: baseURL
  });
}
// 修改职位矩阵数据
export function PutPositionSystem(data: any) {
  return ajaxService({
    url: '/hr/organization/position_management/position_management/position/system',
    method: 'PUT',
    baseURL: baseURL,
    data
  });
}
// 新增职位矩阵数据
export function PostPositionSystem(data: any) {
  return ajaxService({
    url: '/hr/organization/position_management/position_management/position/system',
    method: 'POST',
    baseURL: baseURL,
    data
  });
}

// 获取职位发展通道
export function GetPositionDevelopment() {
  return ajaxService({
    url: '/hr/organization/position_management/position_management/position/channel',
    method: 'get',
    baseURL: baseURL
  });
}

// 修改职位矩阵数据
export function PutPositionDevelopment(data: any) {
  return ajaxService({
    url: '/hr/organization/position_management/position_management/position/channel',
    method: 'PUT',
    baseURL: baseURL,
    data
  });
}
// 新增职位矩阵数据
export function PostPositionDevelopment(data: any) {
  return ajaxService({
    url: '/hr/organization/position_management/position_management/position/channel',
    method: 'POST',
    baseURL: baseURL,
    data
  });
}
